home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-12 | 3.6 KB | 141 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: View.cpp
- // Release Version: $ ODF 2 $
- //
- // Author: Mary Boetcher
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "IntlTest.hpp"
-
- #ifndef VIEW_H
- #include "View.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfIntlTest
- #endif
-
- //========================================================================================
- // CIntlTestView
- //========================================================================================
-
- FW_DEFINE_CLASS_M1(CIntlTestView, FW_CSuperView);
-
- //----------------------------------------------------------------------------------------
- // CIntlTestView::CIntlTestView
- //----------------------------------------------------------------------------------------
-
- CIntlTestView::CIntlTestView(Environment* ev, FW_CSuperView* container,
- const FW_CRect& contentRect, const FW_CPoint& extent)
- : FW_CSuperView(ev, container, contentRect, 0, extent, FW_kNoScrolling)
- {
- // Adjust the bounds but don't redraw now
- CenterInFrame(ev, contentRect.Size(), FW_kDontRedraw);
- }
-
- //----------------------------------------------------------------------------------------
- // CIntlTestView::~CIntlTestView
- //----------------------------------------------------------------------------------------
-
- CIntlTestView::~CIntlTestView()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CIntlTestView::Draw
- //----------------------------------------------------------------------------------------
-
- void CIntlTestView::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- // Set up drawing context for this view
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
-
- // Erase with white first
- FW_CRect invalidRect;
- vc.GetClipRect(invalidRect);
- FW_CRectShape::RenderRect(vc, invalidRect, FW_kFill, FW_kWhiteEraseInk);
- }
-
- //----------------------------------------------------------------------------------------
- // CIntlTestView::CenterInFrame
- //----------------------------------------------------------------------------------------
-
- void CIntlTestView::CenterInFrame(Environment* ev, FW_CPoint& contentSize, FW_ERedrawVerb redraw)
- {
- FW_CPoint viewSize(GetSize(ev));
- FW_CPoint viewExtent(GetExtent(ev));
- FW_CPoint viewLoc;
-
- // Center the content view if it's smaller, or align it if it's bigger
- if (viewSize != contentSize)
- {
- if (contentSize.x > viewExtent.x)
- {
- viewLoc.x = FW_Half(contentSize.x - viewExtent.x);
- viewSize.x = viewExtent.x;
- }
- else
- {
- viewLoc.x = FW_kFixed0;
- viewSize.x = contentSize.x;
- }
-
- if (contentSize.y > viewExtent.y)
- {
- viewLoc.y = FW_Half(contentSize.y - viewExtent.y);
- viewSize.y = viewExtent.y;
- }
- else
- {
- viewLoc.y = FW_kFixed0;
- viewSize.y = contentSize.y;
- }
-
- SetLocation(ev, viewLoc, redraw);
- SetSize(ev, viewSize, redraw);
- }
- }
-
-